package com.xgs.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xgs.common.utils.StringUtils;
import com.xgs.system.domain.RosterHistory;
import com.xgs.system.mapper.RosterHistoryMapper;
import com.xgs.system.service.RosterHistoryService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author JerryLu
 * @date 2024/10/23 11:01
 * @description 名单下发历史信息Service业务层处理
 */
@Service
public class RosterHistoryServiceImpl extends ServiceImpl<RosterHistoryMapper, RosterHistory> implements RosterHistoryService {
    @Override
    public List<RosterHistory> queryList(RosterHistory history) {
        QueryWrapper<RosterHistory> queryWrapper = Wrappers.query();
        if (StringUtils.isNotEmpty(history.getVersion())) {
            queryWrapper.eq("version", history.getVersion());
        }
        if (StringUtils.isNotEmpty(history.getDeptId())) {
            queryWrapper.eq("dept_id", history.getDeptId());
        }
        if (StringUtils.isNotEmpty(history.getVehicleId())) {
            queryWrapper.like("vehicle_id", history.getVehicleId());
        }
        if (StringUtils.isNotEmpty(history.getVersion())) {
            queryWrapper.eq("version", history.getVersion());
        }
        if (StringUtils.isNotEmpty(history.getBeginRoadNo())) {
            queryWrapper.eq("begin_road_no", history.getBeginRoadNo());
        }
        if (StringUtils.isNotEmpty(history.getEndRoadNo())) {
            queryWrapper.eq("end_road_no", history.getEndRoadNo());
        }
        if (StringUtils.isNotEmpty(history.getEnStationId())) {
            queryWrapper.eq("en_station_id", history.getEnStationId());
        }
        if (StringUtils.isNotEmpty(history.getExStationId())) {
            queryWrapper.eq("ex_station_id", history.getExStationId());
        }
        if (StringUtils.isNotEmpty(history.getEnStationHex())) {
            queryWrapper.eq("en_station_hex", history.getEnStationHex());
        }
        if (StringUtils.isNotEmpty(history.getExStationHex())) {
            queryWrapper.eq("ex_station_hex", history.getExStationHex());
        }
        queryWrapper.orderByDesc("create_time");
        return this.list(queryWrapper);
    }
}
